package org.liuyunfeng.domain;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserMapper {

    @Update("UPDATE user SET age = 100 WHERE age = 20")
    Integer updateNewUser20();

    @Select("SELECT * FROM user WHERE age = #{age}")
    List<NewUser> selectNewUser(@Param("age")Integer age);

    @Insert("INSERT INTO user (username, age, sex) VALUES (#{username}, #{age}, #{sex})")
    Boolean insert(User user);

    Boolean insertBatch(@Param("users") List<User> users);


    @Delete("DELETE FROM user WHERE id = #{id}")
    void delete(@Param("id") Integer id);


    @Select("SELECT COUNT(*) FROM user")
    int count();
}
